const { CollectionCategory } = require('../../../model/collectionCategory');
const { Collection } = require('../../../model/collection');

module.exports = async (req, res) => {
	let list = []
  categories = await CollectionCategory.find()
  categories.forEach(async (item, index) => {
	const collections = await Collection.find({category: item._id})
	list.push({value: collections.length, name: item.name})
	if (index === categories.length - 1) {
		res.json({
		    data: list
		})
	}
  })
  // res.json({
  //     data: list
  // })
}